version: '3'
services:
  web:
    image: maplegend/minute-of-fame
    build: .
    command: /bin/sh -c "python manage.py migrate && python manage.py createcachetable && python manage.py runserver 0.0.0.0:80"
    env_file:
      - ./service.env
      - ./web.env
      - ./db.env
      - ./secret.env
    ports:
      - 80:80
    environment:
      - NODE_ENV=production
      - RHOST=redis
    networks:
      - main
    depends_on:
      - db

  distributor:
    env_file:
      - ./service.env
      - ./secret.env
    image: rg.nl-ams.scw.cloud/minuteoffame/websocket-distributor:master
    hostname: distributor
    networks:
      - main
    depends_on:
      - web
    ports:
      - 4321:4321

  chat:
    env_file:
      - ./service.env
    image: rg.nl-ams.scw.cloud/minuteoffame/mof-chat:master
    hostname: chat
    networks:
      - main
    depends_on:
      - distributor

  queue:
    env_file:
      - ./service.env
    image: rg.nl-ams.scw.cloud/minuteoffame/mof-queue:master
    hostname: queue
    networks:
      - main
    depends_on:
      - distributor

  poll:
    env_file:
      - ./service.env
    image: rg.nl-ams.scw.cloud/minuteoffame/mof-poll:master
    hostname: poll
    networks:
      - main
    depends_on:
      - distributor

  db:
    env_file:
      - ./db.env
    image: postgres:alpine
    restart: always
    hostname: db
    networks:
      - main
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - ./pg_data:/var/lib/postgresql/pg_data

  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080
    networks:
      - main

  kurento:
    hostname: kurento
    image: kurento/kurento-media-server
    network_mode: host
    volumes:
      - ./recs:/recs

  stream:
    env_file:
      - ./service.env
    image: rg.nl-ams.scw.cloud/minuteoffame/mof-stream:master
    hostname: stream
    environment:
      - KMS_URL=ws://192.168.0.1:8888/kurento
    networks:
      - main
      - dockernet
    depends_on:
      - kurento
      - distributor

networks:
  main:
  dockernet:
    external: true
